﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MDS
{
    /// <summary>
    /// 交易类别
    /// </summary>
    public class TradeType : EnumBase<string>
    {

        private TradeType(string id) : base(id) { }
        private static Dictionary<string, TradeType> _allTradeTypes;
        static TradeType()
        {
            正常买卖 = new TradeType("A0");
            新股认购 = new TradeType("A1");
            配股 = new TradeType("A5");
            转股回售 = new TradeType("B3");
            申购赎回 = new TradeType("B7");
            资金划拔 = new TradeType("B8");
            权证行权 = new TradeType("C1");
            质押申转 = new TradeType("C3");
            _allTradeTypes = new Dictionary<string, TradeType>();
            _allTradeTypes.Add(正常买卖._value, 正常买卖);
            _allTradeTypes.Add(新股认购._value, 新股认购);
            _allTradeTypes.Add(配股._value, 配股);
            _allTradeTypes.Add(转股回售._value, 转股回售);
            _allTradeTypes.Add(申购赎回._value, 申购赎回);
            _allTradeTypes.Add(资金划拔._value, 资金划拔);
            _allTradeTypes.Add(权证行权._value, 权证行权);
            _allTradeTypes.Add(质押申转._value, 质押申转);
        }

        public static bool TryParse(string tradeTypeId, out TradeType tradeType)
        {
            if (_allTradeTypes.ContainsKey(tradeTypeId))
            {
                tradeType = _allTradeTypes[tradeTypeId];
                return true;
            }
            else
            {
                tradeType = default(TradeType);
                return false;
            }
        }

        public static TradeType 正常买卖 { get; private set; }
        public static TradeType 新股认购 { get; private set; }
        public static TradeType 配股 { get; private set; }
        public static TradeType 转股回售 { get; private set; }
        public static TradeType 申购赎回 { get; private set; }
        public static TradeType 资金划拔 { get; private set; }
        public static TradeType 权证行权 { get; private set; }
        public static TradeType 质押申转 { get; private set; }

    }
}
